import java.awt.event.*;
import javax.swing.*;

public class NewCustomerButton extends JButton{
	//	Local Variables
	private JFrame _parentFrame;
	private StoreLogic _logic;
	
	public NewCustomerButton(JFrame aParentFrame, StoreLogic alogic)
	{
		super("Add a Customer");
		_parentFrame = aParentFrame;
		_logic = alogic;
		this.addActionListener(new CreateDialogListener());
	}
	
	private class CreateDialogListener implements ActionListener 
	{
		public void actionPerformed(ActionEvent e) 
		{
			AddCustomerFrame _NewCustomerFrame = new AddCustomerFrame(_parentFrame);
			//	Checks the way the frame was closed
			if (_NewCustomerFrame.getDefaultCloseOperation() == 0)
			{
				_logic.addCustomer(_NewCustomerFrame.get_newCustomer());
			}
		}
	}
}
